//
//  WeekPageController.m
//  MindBox
//
//  Created by MS on 16-1-14.
//  Copyright (c) 2016年 Lemon. All rights reserved.
//

#import "WeekPageController.h"
#import "WeekPageView.h"
#import "WeekPageTool.h"
#import "GoodsController.h"
@interface WeekPageController ()<WeekPageViewDelegate>

@property (nonatomic,weak) WeekPageView * weekPageView ;

@end

@implementation WeekPageController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self setNavBar];
    
    
    WeekPageView * view = [[WeekPageView alloc] initWithFrame:CGRectMake(0, 64, self.view.width, self.view.height-64)];
    view.delegate = self;
    [self.view addSubview:view];
    self.weekPageView = view;
    
    [self loadWeekPageData];
    
}

-(void)loadWeekPageData
{
    [WeekPageTool weekPageDataWithSuccess:^(WeekPageModel *data) {
        
        self.weekPageView.weekData = data;
        self.weekPageView.index = self.index;
        
    } failure:^(NSError *error) {
        
    }];
    
}

-(void)weekPageDidClick:(WeekPageView *)weekView goods:(Gift_ItemGoods *)goods index:(NSInteger)index
{
    GoodsController * vc  = [[GoodsController alloc] init];
    vc.good_id = goods.goods_id;
    [self.navigationController pushViewController:vc animated:YES];

}

-(void)setNavBar
{
    MyNavigationItem * leftItem = [MyNavigationItem navigationItemWithImage:@"left_go" andHighlightImage:@"left_go" andTag:0 andTitle:nil addTarget:self action:@selector(leftBtnClick)];
    
    MyNavigationItem * rightItem =[MyNavigationItem navigationItemWithImage:@"threedot" andHighlightImage:@"threedot" andTag:0 andTitle:nil addTarget:self action:@selector(rightClick)];
    
    MyNavigationBar * navBar = [[MyNavigationBar alloc]initWithFrame:CGRectMake(0, 20, self.view.width, 44)];
    
    UIView * lineView = [[UIView alloc] initWithFrame:CGRectMake(0, navBar.frame.size.height-0.5, navBar.frame.size.width, 0.5)];
    lineView.backgroundColor =[UIColor grayColor];
    [navBar addSubview:lineView];
    
    [navBar setNavigationBarWithBgImageName:@"无" andTitle:@"礼物排行榜" andTitleView:nil  andLeftItems:@[leftItem] andRightItems:@[rightItem]];
    [self.view addSubview:navBar];
    
}

-(void)leftBtnClick{
    
    [self.navigationController popViewControllerAnimated:YES];
}


-(void)rightClick{
    
    
}

-(void)dealloc
{
//    NSLog(@"WeekPageController卸载");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
